package com.corona.game;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.corona.Game;
import com.corona.game.util.SpriteProxy;
import com.corona.game.util.TextureCache;
import java.util.Locale;

/* compiled from: Menu.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/DrawStatsScreen.class */
public class DrawStatsScreen extends Menu {
    Sprite helperSprite;
    Pokemon pokemon;
    int pokeIndex;
    Sprite healthSprite;
    PokemonIntroAnim intro;
    char[] levelChars;
    Sprite healthSpriteGreen;
    Sprite healthSpriteYellow;
    Sprite healthSpriteRed;
    int targetSize;
    public Action.Layer layer = Action.Layer.gui_106;
    Sprite[] bgSprites = new Sprite[3];
    public int currIndex = 0;

    public DrawStatsScreen(Game game, Pokemon pokemon, Menu prevMenu) {
        this.prevMenu = prevMenu;
        for (int i = 0; i < 3; i++) {
            this.bgSprites[i] = new Sprite(TextureCache.get(Gdx.files.internal("menu/stats_screen" + String.valueOf(i + 1) + ".png")), 0, 0, 160, 144);
        }
        this.pokemon = pokemon;
        this.pokeIndex = DrawPokemonMenu.allPokemon.indexOf(pokemon);
        this.healthSprite = new Sprite(TextureCache.get(Gdx.files.internal("battle/health1.png")), 0, 0, 1, 2);
        this.intro = new PokemonIntroAnim(null);
        this.healthSpriteGreen = new SpriteProxy(new Color(0.9375f, 0.8125f, 0.46875f, 1.0f), TextureCache.get(Gdx.files.internal("battle/gsc/health1.png")), 0, 0, 1, 2);
        this.healthSpriteYellow = new SpriteProxy(new Color(0.9375f, 0.8125f, 0.46875f, 1.0f), TextureCache.get(Gdx.files.internal("battle/gsc/health_yellow.png")), 0, 0, 1, 2);
        this.healthSpriteRed = new SpriteProxy(new Color(0.9375f, 0.8125f, 0.46875f, 1.0f), TextureCache.get(Gdx.files.internal("battle/gsc/health_red.png")), 0, 0, 1, 2);
    }

    @Override // com.corona.game.Action
    public String getCamera() {
        return "gui";
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.Action
    public void firstStep(Game game) {
        game.battle.oppPokemon = this.pokemon;
        game.insertAction(new WaitFrames(game, 4, new PlayMusic(this.pokemon, (Action) null)));
        game.insertAction(this.intro);
        this.healthSpriteGreen = new SpriteProxy(new Color(0.9375f, 0.8125f, 0.46875f, 1.0f), TextureCache.get(Gdx.files.internal("battle/gsc/health1.png")), 0, 0, 1, 2);
        this.healthSpriteYellow = new SpriteProxy(new Color(0.9375f, 0.8125f, 0.46875f, 1.0f), TextureCache.get(Gdx.files.internal("battle/gsc/health_yellow.png")), 0, 0, 1, 2);
        this.healthSpriteRed = new SpriteProxy(new Color(0.9375f, 0.8125f, 0.46875f, 1.0f), TextureCache.get(Gdx.files.internal("battle/gsc/health_red.png")), 0, 0, 1, 2);
        this.targetSize = (int) Math.ceil((double) ((((float) this.pokemon.currentStats.get("hp").intValue()) * 48.0f) / ((float) this.pokemon.maxStats.get("hp").intValue())));
        if (this.targetSize > 23) {
            this.healthSprite = this.healthSpriteGreen;
        } else if (this.targetSize > 10) {
            this.healthSprite = this.healthSpriteYellow;
        } else {
            this.healthSprite = this.healthSpriteRed;
        }
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        game.uiBatch.draw(this.bgSprites[this.currIndex], 0.0f, 0.0f);
        Sprite sprite = new Sprite((Sprite) this.pokemon.sprite);
        sprite.flip(true, false);
        game.uiBatch.draw(sprite, (56.0f - this.pokemon.sprite.getWidth()) / 2.0f, 88.0f);
        this.levelChars = String.valueOf(this.pokemon.level).toCharArray();
        int offset = -8 * (this.pokemon.level / 100);
        for (char c : this.levelChars) {
            game.uiBatch.draw(game.textDict.get(Character.valueOf(c)), (float) (120 + offset), 136.0f);
            offset += 8;
        }
        if (this.pokemon.gender.equals("male")) {
            game.uiBatch.draw(TextureCache.maleSymbol, 144.0f, 136.0f);
        } else if (this.pokemon.gender.equals("female")) {
            game.uiBatch.draw(TextureCache.femaleSymbol, 144.0f, 136.0f);
        }
        if (this.pokemon.isShiny) {
            game.uiBatch.draw(TextureCache.shinySymbol, 152.0f, 136.0f);
        }
        char[] textArray = this.pokemon.nickname.toUpperCase(Locale.ROOT).toCharArray();
        for (int j = 0; j < textArray.length; j++) {
            game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray[j])), (float) (64 + (8 * j)), 120.0f);
        }
        if (this.currIndex == 0) {
            int currHealth = this.pokemon.currentStats.get("hp").intValue();
            int hundredsPlace = currHealth / 100;
            if (hundredsPlace > 0) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(Character.forDigit(hundredsPlace, 10))), 8.0f, 56.0f);
            }
            int tensPlace = (currHealth % 100) / 10;
            if (tensPlace > 0 || hundredsPlace > 0) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(Character.forDigit(tensPlace, 10))), 16.0f, 56.0f);
            }
            game.uiBatch.draw(game.transparentDict.get(Character.valueOf(Character.forDigit(currHealth % 10, 10))), 24.0f, 56.0f);
            int maxHealth = this.pokemon.maxStats.get("hp").intValue();
            int hundredsPlace2 = maxHealth / 100;
            if (hundredsPlace2 > 0) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(Character.forDigit(hundredsPlace2, 10))), 40.0f, 56.0f);
            }
            int tensPlace2 = (maxHealth % 100) / 10;
            if (tensPlace2 > 0 || hundredsPlace2 > 0) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(Character.forDigit(tensPlace2, 10))), 48.0f, 56.0f);
            }
            game.uiBatch.draw(game.transparentDict.get(Character.valueOf(Character.forDigit(maxHealth % 10, 10))), 56.0f, 56.0f);
            String text = "OK";
            if (this.pokemon.status != null) {
                if (this.pokemon.status.equals("poison") || this.pokemon.status.equals("toxic")) {
                    text = "PSN";
                } else if (this.pokemon.status.equals("paralyze")) {
                    text = "PAR";
                } else if (this.pokemon.status.equals("freeze")) {
                    text = "FRZ";
                } else if (this.pokemon.status.equals("sleep")) {
                    text = "SLP";
                } else if (this.pokemon.status.equals("burn")) {
                    text = "BRN";
                }
            }
            char[] textArray2 = text.toCharArray();
            for (int j2 = 0; j2 < textArray2.length; j2++) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray2[j2])), (float) (48 + (8 * j2)), 32.0f);
            }
            char[] textArray3 = this.pokemon.types.get(0).toCharArray();
            for (int j3 = 0; j3 < textArray3.length; j3++) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray3[j3])), (float) (8 + (8 * j3)), 16.0f);
            }
            char[] textArray4 = this.pokemon.types.get(1).toCharArray();
            for (int j4 = 0; j4 < textArray4.length && !this.pokemon.types.get(0).equals(this.pokemon.types.get(1)); j4++) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray4[j4])), (float) (8 + (8 * j4)), 8.0f);
            }
            String exp = String.valueOf(this.pokemon.exp);
            String text2 = "";
            for (int i = 0; i < 10 - exp.length(); i++) {
                text2 = text2 + " ";
            }
            char[] textArray5 = (text2 + exp).toCharArray();
            for (int j5 = 0; j5 < textArray5.length; j5++) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray5[j5])), (float) (80 + (8 * j5)), 56.0f);
            }
            for (int j6 = 0; j6 < this.targetSize; j6++) {
                game.uiBatch.draw(this.healthSprite, (float) (16 + (1 * j6)), 67.0f);
            }
            String exp2 = String.valueOf(this.pokemon.calcExpForLevel(this.pokemon.level + 1) - this.pokemon.exp);
            String text3 = "";
            for (int i2 = 0; i2 < 10 - exp2.length(); i2++) {
                text3 = text3 + " ";
            }
            char[] textArray6 = (text3 + exp2).toCharArray();
            for (int j7 = 0; j7 < textArray6.length; j7++) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray6[j7])), (float) (80 + (8 * j7)), 32.0f);
            }
            char[] textArray7 = String.valueOf(this.pokemon.level + 1).toCharArray();
            for (int j8 = 0; j8 < textArray7.length; j8++) {
                game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray7[j8])), (float) (144 + (8 * j8)), 24.0f);
            }
        } else if (this.currIndex == 1) {
            for (int i3 = 0; i3 < this.pokemon.attacks.length; i3++) {
                String attack = this.pokemon.attacks[i3];
                if (attack == null) {
                    attack = "-";
                }
                char[] textArray8 = attack.toUpperCase(Locale.ROOT).toCharArray();
                for (int j9 = 0; j9 < textArray8.length; j9++) {
                    game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray8[j9])), (float) (64 + (8 * j9)), (float) (56 - (i3 * 16)));
                }
            }
        } else {
            if (this.pokemon.previousOwner != null) {
                char[] textArray9 = this.pokemon.previousOwner.name.toUpperCase(Locale.ROOT).toCharArray();
                for (int j10 = 0; j10 < textArray9.length; j10++) {
                    game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray9[j10])), (float) (16 + (8 * j10)), 32.0f);
                }
            }
            String[] allStats = {"attack", "defense", "specialAtk", "specialDef", "speed"};
            for (int i4 = 0; i4 < allStats.length; i4++) {
                String val = String.valueOf(this.pokemon.maxStats.get(allStats[i4]));
                String text4 = "";
                for (int k = 0; k < 3 - val.length(); k++) {
                    text4 = text4 + " ";
                }
                char[] textArray10 = (text4 + val).toCharArray();
                for (int j11 = 0; j11 < textArray10.length; j11++) {
                    game.uiBatch.draw(game.transparentDict.get(Character.valueOf(textArray10[j11])), (float) (136 + (8 * j11)), (float) (64 - (16 * i4)));
                }
            }
        }
        if (InputProcessor.upJustPressed && this.prevMenu != null) {
            int newIndex = this.pokeIndex - 1;
            int newIndex2 = newIndex < 0 ? DrawPokemonMenu.allPokemon.size() - 1 : newIndex;
            if (newIndex2 != this.pokeIndex) {
                scrollToNewPokemon(game, newIndex2);
            }
        } else if (InputProcessor.downJustPressed && this.prevMenu != null) {
            int newIndex3 = this.pokeIndex + 1;
            int newIndex4 = newIndex3 >= DrawPokemonMenu.allPokemon.size() ? 0 : newIndex3;
            if (newIndex4 != this.pokeIndex) {
                scrollToNewPokemon(game, newIndex4);
            }
        } else if (InputProcessor.leftJustPressed) {
            if (this.currIndex > 0) {
                this.currIndex--;
            }
        } else if (InputProcessor.rightJustPressed && this.currIndex < 2) {
            this.currIndex++;
        }
        if (InputProcessor.bJustPressed && this.prevMenu != null) {
            game.actionStack.remove(this);
            game.insertAction(new Outro(this.prevMenu));
        }
    }

    private void scrollToNewPokemon(Game game, int newIndex) {
        this.intro.currFrame = this.pokemon.introAnim.size();
        DrawPokemonMenu.currIndex = 0;
        DrawPokemonMenu.scrollIndex = 0;
        while (DrawPokemonMenu.currIndex + DrawPokemonMenu.scrollIndex < newIndex) {
            if (DrawPokemonMenu.currIndex < 5) {
                DrawPokemonMenu.currIndex++;
            } else {
                DrawPokemonMenu.scrollIndex++;
            }
        }
        game.actionStack.remove(this);
        DrawStatsScreen newScreen = new DrawStatsScreen(game, DrawPokemonMenu.allPokemon.get(newIndex), this.prevMenu);
        newScreen.currIndex = this.currIndex;
        game.insertAction(new Intro(newScreen));
    }

    /* compiled from: Menu.java */
    /* loaded from: pokewilds.jar:com/pkmngen/game/DrawStatsScreen$Intro.class */
    public static class Intro extends Action {
        public Action.Layer layer;
        int duration;
        Sprite bgSprite;

        public Intro(Action nextAction) {
            super(new Object[0]);
            this.layer = Action.Layer.gui_110;
            this.duration = 30;
            this.nextAction = nextAction;
            this.bgSprite = new Sprite(TextureCache.get(Gdx.files.internal("battle/intro_frame6.png")), 0, 0, 160, 144);
        }

        public Intro(int duration, Action nextAction) {
            this(nextAction);
            this.duration = duration;
        }

        @Override // com.corona.game.Action
        public String getCamera() {
            return "gui";
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return this.layer;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            this.bgSprite.draw(game.uiBatch);
            this.duration--;
            if (this.duration <= 0) {
                game.insertAction(this.nextAction);
                game.actionStack.remove(this);
            }
        }
    }

    /* compiled from: Menu.java */
    /* loaded from: pokewilds.jar:com/pkmngen/game/DrawStatsScreen$Outro.class */
    static class Outro extends Action {
        Menu prevMenu;
        public Action.Layer layer = Action.Layer.gui_110;
        int duration = 34;
        Sprite bgSprite;

        public Outro(Menu prevMenu) {
            super(new Object[0]);
            this.prevMenu = prevMenu;
            if (this.prevMenu != null) {
                this.prevMenu.drawArrowWhite = true;
            }
            this.bgSprite = new Sprite(TextureCache.get(Gdx.files.internal("battle/intro_frame6.png")), 0, 0, 160, 144);
        }

        @Override // com.corona.game.Action
        public String getCamera() {
            return "gui";
        }

        @Override // com.corona.game.Action
        public Action.Layer getLayer() {
            return this.layer;
        }

        @Override // com.corona.game.Action
        public void step(Game game) {
            if (this.prevMenu != null) {
                this.prevMenu.step(game);
            }
            this.duration--;
            if (this.duration > 0) {
                this.bgSprite.draw(game.uiBatch);
            }
            if (this.duration <= 0) {
                if (this.prevMenu != null) {
                    game.insertAction(this.prevMenu);
                    this.prevMenu.disabled = false;
                    this.prevMenu.drawArrowWhite = false;
                }
                game.insertAction(this.nextAction);
                game.actionStack.remove(this);
            }
        }
    }
}
